# Copyright (C) 2010 Razvan Constantin <razvan.constantin@rconst.net>
#
# This file is part of FileBow.
#
# FileBow is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FileBow is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FileBow.  If not, see <http:#www.gnu.org/licenses/>.

# WAF configurator extensions customized for filebow 

import os.path
import Options

def configure_poco(self):
  """ Check for existence of poco libraries """
  self.check_cxx(
      lib='PocoFoundation',
      uselib_store='POCO',
      mandatory=True,
      args='--libs')

def configure_gtk(self):
  """ Check for existence of gtk libraries """
  self.check_cfg(
      package='gtk+-2.0',
      atleast_version='2.6.0',
      uselib_store='GTK',
      mandatory=True,
      args='--cflags --libs',
      path=self.env['CFG_TOOL'])

def configure_geany(self):
  """ Check for existence of geany headers """
  GEANY_PREFIX = self.env['GEANY_INCLUDES']
  GEANY_INCLUDES = [os.path.join(GEANY_PREFIX, INCLUDE) for INCLUDE in ('', 'scintilla', 'tagmanager')]
  self.check_cc(
      header_name='geanyplugin.h',
      mandatory=True,
      defines=['GTK'],
      uselib='GTK',
      uselib_store='GEANY',
      includes=GEANY_INCLUDES + [self.srcdir,])

def configure_gtest(self):
  """ Check for existence of gtest libraries """
  self.check_cxx(
      header_name='gtest/gtest.h',
      uselib_store='GTEST')
  self.env.LIB_GTEST = 'gtest'

def extend(conf):
  import types
  for fn in (configure_poco, configure_gtk, configure_geany, configure_gtest):
    setattr(conf, fn.__name__, types.MethodType(fn, conf))
